package com.atguigu.gmall.web.all.controller;

import com.atguigu.gmall.common.util.AuthContextHolder;

import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.web.all.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 订单页面跳转控制器
 */
@Controller
public class OrderController {

    @Autowired
    OrderService orderService;

    /**
     * 订单列表页
     *
     * @return
     */
    @GetMapping("/myOrder.html")
    public String orderListPage(){

        return "order/myOrder.html";
    }

    /**
     * 来到订单确认页
     * @return
     */
    @GetMapping("/trade.html")
    public String tradeHtml(Model model, HttpServletRequest request){

        /**
         * detailArrayList 商品清单 拿到购物车已经选中的商品清单  给购物车服务发请求order-cart-product
         * 每个商品： imgUrl\skuName\orderPrice\skuNum
         * totalNum:商品数量
         * totalAmount:商品金额
         * userAddressList:用户收货地址列表 给service-user
         * tradeNo:交易号[防止重复提交] 给order发请求
         */
        String userId = AuthContextHolder.getUserId(request);
        Map<String,Object> map = orderService.getOrderConfirmInfo(userId);

        model.addAllAttributes(map);



/*        model.addAttribute("detailArrayList",null);
        model.addAttribute("totalNum",null);
        model.addAttribute("totalAmount",null);
        model.addAttribute("userAddressList",null);
        model.addAttribute("tradeNo","sdsasdadassad");*/
        return "order/trade";
    }
}
